home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Run Magazine ReRun 1985 Summer
/
rerun-1985-summer-side-a.d64
/
play ball
(
.txt
)
< prev
next >
Wrap
Commodore BASIC
|
2022-09-20
|
6KB
|
262 lines
10 dima(20,6),b(20,6),c(20,6),n$(20),a$(20),b$(20),m(6),t(6),u(6)
20 np=0:ad=0:na=0
30 poke53280,11:poke53281,11:printchr$(5)
100 rem ***************** menu ****************
110 printchr$(147):print:printtab(12)"softball stats"
120 print
130 print:print" 1 load previous stats"
140 print:print" 2 add new data"
150 print:print" 3 sort and display stats"
160 print:print" 4 save new data"
170 print:print" 5 add players"
180 print:print" 6 print stats"
190 print:print" 7 quit program"
200 print:print
210 c=0:input" enter your choice";c
220 ifc<1orc>7then210
230 oncgosub1000,2000,3000,4000,5000,8200,11000
240 goto100
1000 rem ********* read old data from tape or disk *********
1005 printchr$(147):gosub9800:iftd$="t"then1011
1010 open2,8,2,"0:softball "+gn$+",s,r":goto1015
1011 open2,1,0,"softball"
1015 input#2,gm
1020 printchr$(147):print"softball stats through game #";gm:print
1030 gosub10000
1035 na=np
1040 np=np+1:input#2,n$(np)
1050 ifn$(np)="end"thennp=np-1:goto1070
1060 goto1040
1070 fori=na+1tonp
1080 forj=1to5
1090 input#2,a(i,j)
1100 nextj
1110 input#2,a$(i)
1130 printn$(i);
1140 x=8
1150 fork=1to5
1160 printtab(x)a(i,k);
1170 x=x+5
1180 nextk
1182 ifa$(i)="1.000"thenx=x-1
1185 printtab(x+1)a$(i)
1190 nexti:close2
1192 fori=1tonp:forj=1to5
1194 c(i,j)=a(i,j)
1196 next:next
1200 gosub6000:gosub6100
1205 iftd$="d"then1230
1210 print:print:printtab(9)"*** turn off tape ***"
1220 ifpeek(192)<>0then1220
1230 gosub9500
1240 return
2000 rem *********** input this weeks data ***********
2005 printchr$(147):print" input new data":print:print
2007 ad=1
2010 fori=1tonp
2020 printn$(i)
2030 gosub8500
2060 gosub2500
2070 print
2080 nexti
2090 gosub10000:gosub8000
2100 rem check for errors
2105 print:printtab(12)"check for errors"
2110 print:print" hit 'e' to correct input errors"
2120 getk$:ifk$=""then2120
2130 ifk$="e"thengosub7000
2140 printchr$(147):print:print" computing..."
2165 rem *** add new data to old
2170 fori=1tonp
2180 forj=1to5
2190 b(i,j)=b(i,j)+a(i,j)
2200 nextj
2210 gosub2500
2230 nexti
2240 gosub8800:gosub6000
2250 return
2500 rem *************** compute avg ***************
2510 ifb(i,1)=0thenb(i,6)=0:goto2550
2520 b(i,6)=b(i,2)/b(i,1)
2530 b(i,6)=int(b(i,6)*1000+.5)/1000
2540 ifb(i,6)=1thenb$(i)="1.000":goto2600
2550 ifb(i,6)=0thenb$(i)=" .000":goto2600
2560 b$(i)=str$(b(i,6)):l=len(b$(i))
2570 ifl=3thenb$(i)=b$(i)+"00":goto2600
2580 ifl=4thenb$(i)=b$(i)+"0"
2600 return
3000 rem ************* shell sort ********************
3005 ifad=0thenad=1:gosub2170
3007 gosub9000
3008 printchr$(147);:print" computing...."
3010 n=np
3020 g=int(n/2)
3030 ifg=0then3160
3040 fori=1ton-g
3050 ifb(i,s)>=b(i+g,s)then3100
3060 forj=1to6:t(j)=b(i,j):u(j)=a(i,j):next
3062 t$=n$(i):tb$=b$(i)
3070 forj=1to6:b(i,j)=b(i+g,j):a(i,j)=a(i+g,j):next
3072 n$(i)=n$(i+g):b$(i)=b$(i+g)
3080 forj=1to6:b(i+g,j)=t(j):a(i+g,j)=u(j):next
3082 n$(i+g)=t$:b$(i+g)=tb$
3090 e=1
3100 next
3110 ife=0then3140
3120 e=0
3130 goto3030
3140 g=int(g/2)
3150 goto3030
3160 printchr$(147):print:gosub10000
3165 print:gosub8000:gosub8800
3170 gosub6000:gosub6100
3180 print:gosub9500:return
4000 rem ******** save new stats to tapeor disk *********
4002 printchr$(147):print:print
4005 gosub9800:iftd$="t"then4011
4010 open2,8,2,"0:softball "+gn$+",s,w":goto4015
4011 open2,1,1,"softball"
4015 print#2,ga
4020 fori=1tonp
4030 print#2,n$(i)
4040 next
4045 print#2,n$(np+1)
4050 fori=1tonp
4060 forj=1to5
4070 print#2,b(i,j)
4080 nextj
4085 print#2,b$(i)
4090 nexti
4100 close2
4102 print:print:printtab(12)"new stats saved"
4104 iftd$="d"then4110
4105 print:printtab(13)"turn off tape"
4106 ifpeek(192)<>0then4106
4110 print:gosub9500:return
5000 rem *********add players (or start year) **********
5010 printchr$(147):print:print" enter 'end' after last player":print
5020 np=np+1
5030 input"name";n$(np)
5035 iflen(n$(np))>8thenn$(np)=left$(n$(np),8)
5040 ifn$(np)="end"thennp=np-1:goto5100
5050 forj=1to6
5060 a(np,j)=0
5070 next
5080 b$(np)=" .000"
5090 print:goto5020
5100 return
6000 rem ************ team totals (m) **************
6010 fori=1to5:m(i)=0:next:print
6020 forj=1to5
6030 fori=1tonp
6040 m(j)=m(j)+c(i,j)
6050 next
6060 next
6070 ifm(1)=0thenm(6)=0:goto6093
6080 m(6)=m(2)/m(1)
6090 m(6)=int(m(6)*1000+.5)/1000
6092 ifm(6)=1thenm$="1.000":goto6099
6093 ifm(6)=0thenm$=" .000":goto6099
6095 m$=str$(m(6)):l=len(m$)
6097 ifl=3thenm$=m$+"00":goto6099
6098 ifl=4thenm$=m$+"0"
6099 return
6100 x=8
6110 print"totals";
6120 forj=1to5
6130 printtab(x)m(j);
6140 x=x+5
6150 next
6155 printtab(x)m$
6160 return
7000 rem ************ error correction ************
7010 printchr$(147):print:printtab(12)"error correction":print:print
7020 pf=0:input"name of player";c$:print
7030 fori=1tonp
7040 ifc$<>n$(i)then7060
7050 pf=1:gosub8500
7060 nexti
7065 ifpf=0thenprint"player not found, try again":print:goto7020
7070 print:input"more corrections (y/n)";mc$
7080 ifmc$="n"thenreturn
7090 ifmc$="y"then7010
7100 goto7070
8000 rem ********** print stats (screen) ***********
8010 fori=1tonp
8020 printn$(i);
8030 x=8
8040 forj=1to5
8050 printtab(x)b(i,j);
8060 x=x+5
8070 next
8072 printtab(x)b$(i)
8080 next
8090 return
8200 rem ************ stats to printer ************
8210 ifad=0thenad=1:gosub2170
8215 printchr$(147):input"stats through game #";gn
8220 print:print" turn printer on, set pitch, margins"
8225 print:print"and line spacing.":print:print
8230 gosub9500
8240 open4,4:cmd4
8245 print"softball stats through game #";gn
8250 print
8260 print"name"spc(8)"ab"spc(6)"h"spc(7)"r"spc(7)"rbi"spc(5)"bb"spc(7)"avg"
8270 print
8280 fori=1tonp
8285 zz=11-len(n$(i))
8290 printn$(i);spc(zz);
8300 forj=1to5
8305 zz=7-(len(str$(b(i,j))))
8310 printb(i,j);spc(zz);
8320 nextj
8330 printb$(i)
8340 nexti
8350 print:print"totals ";
8360 forj=1to5
8365 zz=7-(len(str$(m(j))))
8370 printm(j);spc(zz);
8380 next
8390 printm$
8400 print#4:close4
8410 return
8500 rem ************** input stats **************
8510 input"abs";b(i,1)
8520 input"hits";b(i,2)
8530 input"runs";b(i,3)
8540 input"rbis";b(i,4)
8550 input"walks";b(i,5)
8570 return
8800 rem ****** set c(x,x) before totals******
8810 fori=1tonp:forj=1to5
8820 c(i,j)=b(i,j)
8830 next:next
8840 return
9000 rem *************** sort menu ***************
9010 printchr$(147):print:print "which category do you want to sort by?"
9020 print
9030 print:print" 1 at bats"
9040 print:print" 2 hits"
9050 print:print" 3 runs"
9060 print:print" 4 rbis"
9070 print:print" 5 walks"
9080 print:print" 6 average"
9090 print:print:print
9100 input" enter your choice";s
9110 ifs<1ors>6then9100
9120 return
9500 rem *************** get key *************
9510 print:printtab(15)"hit a key"
9520 getk$:ifk$=""then9520
9530 return
9800 rem *** get tape or disk input ***
9810 input"tape or disk (t/d)";td$
9820 iftd$<>"d"andtd$<>"t"then9810
9840 print:input"stats through game number";gn$:ga=val(gn$)
9850 return
10000 rem ************** print headings ************
10010 print"name";tab(9)"ab";tab(14)"h";tab(19)"r";tab(23)"rbi";tab(29)"bb";
10020 printtab(35)"avg"
10030 return
11000 printchr$(147):end:rem ****** quit ******